package com.zygh.lz.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zygh.lz.entity.duty.DutyModel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;
import java.util.Map;

/**
 * @author lee
 */
@Mapper
public interface DutyModelMapper extends BaseMapper<DutyModel> {
    @Insert(value = "<script>" +
            " INSERT INTO duty_mode" +
            " (code,name,last_time) " +
            " VALUES (#{code},#{name},#{lastTime}) " +
            " </script>")
    @SelectKey(statement="select LAST_INSERT_ID()",keyProperty = "id",before = false,resultType = Integer.class)
    Integer insertId(DutyModel dutyModel);


    @Select("SELECT id,post_code postCode,post_name postName FROM duty_post")
    List<Map<String,Object>> findDutyModeAll();

    @Select("SELECT name FROM duty_mode where code = #{pattern}")
    String getByCode(Integer pattern);
}
